﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>字典明细管理</title>
    <#include "../common/link.ftl">
    <script>
        $(function () {

            $('.btn-input').click(function () {

                $('#editForm')[0].reset();

                var data = $(this).data('json');
                console.log(data);

                $('.modal-title').html("字典明细添加")

                //在模态框显示之前,获取点击的li
                var $li = $('#systemDictionaries>li.active');
                var id = $li.attr('systemdictionaryid');
                var title = $li.html();

                var $option = $('[name="systemDictionary.id"]>option');
                $option.val(id)
                $option.html(title)


                if (data) {
                    $('.modal-title').html("字典明细编辑")
                    $('input[name="id"]').val(data.id)
                    $('input[name="title"]').val(data.title)
                    $('input[name="sequence"]').val(data.sequence)
                    $option.val(data.systemDictionaryId)
                    $option.html(data.systemDictionaryTitle)
                }


                $('#editModal').modal('show')
            })


            $('.btn-submit').click(function () {
                $('#editForm').ajaxSubmit(function (data) {
                    if (data.success) {
                        $.messager.confirm("温馨提示", data.msg, function () {
                            window.location.reload();
                        });
                    } else {
                        $.messager.alert("温馨提示", data.msg)
                    }
                })


            })


            $('.system-dictionary').click(function () {
                var id = $(this).attr('systemDictionaryId');
                $('#parentId').val(id)
                $('#searchForm').submit();
            })


        })
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
     <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="systemDictionaryitem">
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>字典明细管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <div class="row box-body">
                    <div class="col-md-3">
                        <ul id="systemDictionaries" class="list-group">
                            <#list systemDictionaries as systemDictionary>
                                <li class="list-group-item system-dictionary <#if qo.parentId?? && qo.parentId==systemDictionary.id>active</#if>"
                                    systemDictionaryID="${systemDictionary.id}">${systemDictionary.title}</li>
                            <#--
                                                                <a style="color: #333333" href="/systemDictionaryitem/list.do?parentId=${systemDictionary.id}">${systemDictionary.title}</a>
                            -->
                                </li>
                            </#list>
                        </ul>
                    </div>
                    <div class="col-md-9">
                        <!--高级查询--->
                        <form class="form-inline" id="searchForm" action="/systemDictionaryitem/list.do"
                              method="post">
                            <input type="hidden" name="currentPage" id="currentPage" value="1">
                            <input type="hidden" name="parentId" id="parentId" value="${(qo.parentId)!}">
                                <#if qo.parentId??>
                            <a data-url="/systemDictionaryitem/input.do" class="btn btn-success btn-input">
                                <span class="glyphicon glyphicon-plus"></span> 添加
                            </a>
                                </#if>
                        </form>
                        <!--编写内容-->
                        <div class="table-responsive no-padding ">
                            <table class="table table-hover table-bordered">
                                <tr>
                                    <th>编号</th>
                                    <th>字典目录</th>
                                    <th>标题</th>
                                    <th>序列</th>
                                    <th>操作</th>
                                </tr>

                                <#list pageInfo.list as systemDictionaryitem>
                                    <tr>
                                        <td>${systemDictionaryitem_index + 1}</td>
                                        <td>${(systemDictionaryitem.systemDictionary.title)!}</td>
                                        <td>${systemDictionaryitem.title}</td>
                                        <td>${systemDictionaryitem.sequence}</td>
                                        <td>
                                            <#if qo.parentId??>
                                                 <a data-json='${systemDictionaryitem.jsonData}'
                                                    class="btn btn-info btn-xs btn-input">
                                                     <span class="glyphicon glyphicon-pencil"></span> 编辑
                                                 </a>
                                            </#if>
                                            <a data-url="/systemDictionaryitem/delete.do?id=${systemDictionaryitem.id}"
                                               class="btn btn-danger btn-xs btn_delete">
                                                <span class="glyphicon glyphicon-trash"></span> 删除
                                            </a>
                                        </td>
                                    </tr>
                                </#list>
                            </table>
                            <!--分页-->
                            <#include "../common/page.ftl">
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl">
</div>
</div>


<!---字典明细编辑模态框--->
<div class="modal fade" id="editModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">字典明细添加</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/systemDictionaryitem/saveOrUpdate.do" method="post"
                      id="editForm">
                    <input type="hidden" value="" name="id">

                    <div class="form-group">
                        <label class="col-sm-3 control-label">字典明细目录：</label>
                        <div class="col-sm-6">
                            <select class="form-control" name="systemDictionary.id" readonly>
                                <option></option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">字典明细名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="title" value="">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">字典明细序列：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="sequence" value="">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary btn-submit">保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
